package gamagora.game.utils
{
	import flash.utils.getTimer;

	public class OSFPSTimer
	{
		private var _fps:Number;
		private var _last:uint;
		private var _ticks:uint;
		private var _now:uint;
		private var _time:uint;
		
		public function OSFPSTimer()
		{
			_fps = 0;
			_last = 0;
			_ticks = 0;
			_now = 0;
			_time = 0;
		}
		
		public function update():void
		{
			this._ticks++;
			this._now = getTimer();
			this._time = _now - _last;
			if(_time >= 1000) 
			{
				_fps = _ticks / _time * 1000;
				this._ticks = 0;
				this._last = _now;
			}	
		}

		public function get fps():Number
		{
			return _fps;
		}
	}
}